<template>
	<view v-if="msg===''" class="">
		<xbd-zwnz></xbd-zwnz>
	</view>
	<view v-else class="center">
		<view class="title">
			{{msg.task_name}}
		</view>
		<view class="details">
			<view class="">
				<view class="tag">
					内容来源：{{msg.origin}}
				</view>
				<view class="tag">
					发布时间：{{msg.created_at | timeFormat('YYYY-MM-DD HH:mm')}}
				</view>
			</view>
		</view>
		<!-- 富文本编译插件 -->
		<parser :html="msg.content" :tagStyle='style' />
	</view>
</template>

<script>
	import parser from '@/components/jyf-parser/jyf-parser.vue';
	import {
		Mission
	} from '@/api/index.js';
	export default {

		data() {
			return {
				isClick: false,
				id: '',
				msg: '',
				style: {
					'img': 'display:block;margin: 0 auto;max-width:100%;height:auto; transform: translateX(0);',
					'video': 'width:100%;height:auto;',
				},
			};
		},
		components: {
			parser
		},
		methods: {
			collection() {
				this.isClick = !this.isClick
			},
			async init() {
				this.$showLoading('加载中');
				const res = await Mission.getknowledgeDetail(this.id)
				uni.hideLoading();
				if (res.success) {
					this.msg = res.data
				}else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
					})
				}
				console.log(res, 'res')
			}
		},
		async onLoad(res) {
			this.id = res.id
			await this.init()
		}
	}
</script>

<style lang="scss" scoped>
	.center {
		padding: 32rpx;

		.title {
			font-family: PingFang SC, PingFang SC-Heavy;
			white-space: pre-line !important;
			word-break: break-all !important;
			word-wrap: break-word ;
			font-weight: 800;
			line-height: 56rpx;
			font-size: 36rpx;
			color: #000623;
			text-align: justify;
			word-wrap: break-word;
		}

		.details {
			margin-top: 20rpx;
			padding-bottom: 20rpx;
			display: flex;
			justify-content: space-between;
			font-size: 26rpx;
			color: #8890A5;
			align-items: center;
			border-bottom: 2rpx solid #EBEEF5;

			.tag {
				margin-bottom: 20rpx;
			}
		}
	}
</style>
